package com.gitee.alg.jvm

import org.openjdk.jol.info.ClassLayout

/**
 * Project Name: alg
 * Des: 常用对象
 * Package:com.gitee.alg.jvm
 * @author Arlo Sun
 * @date 2021/4/29 - 15:14
 */
fun main(){

    // byte String.coder                              0 -> LATIN1
    val uni = "SunShine"
    uni.hashCode()
    // byte String.coder                              1 -> UTF16
    val utf = "阳光灿烂"


    //String (default -> coops) -> 12 byte header + 4 byte value
    // + 4 byte hash(cache init on first time invoke hashCode)
    // + 1 byte coder ( 0 -> LATIN1,1 -> UTF16) ... 3 byte padding loss
    val again =  java.lang.String("Exactly")

    val x = 3.0

    println(ClassLayout.parseInstance(uni).toPrintable())
    println(ClassLayout.parseInstance(utf).toPrintable())
    println(ClassLayout.parseInstance(again).toPrintable())
    println(ClassLayout.parseInstance(x).toPrintable())
}

